package io.renren.modules.weldingmachine.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import io.renren.modules.weldingmachine.entity.AnalysisInfoResponse;
import io.renren.modules.weldingmachine.entity.UserateInfoResponse;
import io.renren.modules.weldingmachine.entity.WarnInfoResponse;
import io.renren.modules.weldingmachine.service.impl.WeldingmachineServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("weldingmachine/weldingmachine")
public class UserateController {
    private final WeldingmachineServiceImpl weldingmachineService;

    @Autowired
    public UserateController(WeldingmachineServiceImpl weldingmachineService) {
        this.weldingmachineService = weldingmachineService;
    }
    @GetMapping("/userate")
    public ResponseEntity<List<UserateInfoResponse.UserateInfo>> getUserate(
            @RequestParam String startDate,
            @RequestParam String endDate,
            @RequestParam String silkDiameter,
            @RequestParam String silkMeltrate,
            @RequestParam Integer theoWorkTime,
            @RequestParam String pauseRate,
            @RequestParam String gwsn
//            @RequestParam Optional<String> gwsn
            ) throws UnsupportedEncodingException, JsonProcessingException {
        List<UserateInfoResponse.UserateInfo> userateInfos = weldingmachineService.getUserate(startDate, endDate,silkDiameter,silkMeltrate,theoWorkTime,pauseRate,gwsn);
        return ResponseEntity.ok(userateInfos);
    }
}
